package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * @author Administrator
 * @Description
 * PrintWrite 追加模式
 * @date 2022/5/5 9:30
 **/
public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        FileOutputStream fos = new FileOutputStream("pw.txt", true);
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        /**
         * @author
         * @description //TODO
         * 当printwrite的第一个参数为流时,我们就支持再传入一个boolean值参数,
         * 如果该值为true则打开了自动刷新功能
         * @date 2022/5/5 10:33
 * @param args
         */
        PrintWriter pw = new PrintWriter(bw, true);
        pw.println("让我掉下眼泪的,不止昨天的酒");
        pw.println("让我依依不舍的,不止你的温柔");

        Scanner scanner = new Scanner(System.in);
        while (true){
            String line = scanner.nextLine();
            if ("exit".equalsIgnoreCase(line)){
                break;
            }
            pw.println(line);
        }


        pw.close();
    }
}
